import sys

students = {}

def addStudent():
    id = input("请输入学号:")
    name = input("请输入姓名:")
    age = input("请输入年龄:")
    address = input("请输入地址:")
    students[id] = {"id":id, "name": name, "age": age, "address": address}
    print('学生信息添加成功！')

def delStudent():
    id = input("请输入需要删除的学号：")
    s = students.get(id)
    if s == None:
        print("学号不存在")
        return
    else:
        del students[id]
        print("学生信息删除成功！")

def updateStudent():
    id = input("请输入需要修改信息的学号：")
    s = students.get(id)
    if s == None:
        print("学号不存在")
        return
    else:
        name = input("请输入姓名:")
        age = input("请输入年龄:")
        aaddress = input("请输入地址:")
        students.update({id:{"name":name, "age":age, "address": aaddress}})
        print("学生信息修改成功！")

def showStudents():
    for k, v in students.items():
        print("id",v.get("id"))
        print("name",v.get("name"))
        print("age",v.get("age"))
        print("address",v.get("address"))

def menu():
    print("-------------------學生管理系統------------------")
    print("1.新增学生信息")
    print("2.删除学生信息")
    print("3.修改学生信息")
    print("4.查询学生信息")
    print("5.退出系统")
    print("------------------------------------------------")
    menu_num = int(input("请输入功能号:"))
    if menu_num == 1:
        addStudent()
    elif menu_num == 2:
        delStudent()
    elif menu_num == 3:
        updateStudent()
    elif menu_num == 4:
        showStudents()
    elif menu_num == 5:
        sys.exit()
    else:
        print("菜单的功能号不存在！")
if __name__ == '__main__':
    while True:
        menu()